package com.exam.Mapper;

import com.exam.Entity.Teacher;
import org.apache.ibatis.annotations.*;

import java.util.List;

@Mapper
public interface TeacherMapper {

    @Select("select * from teacher")
    List<Teacher> findAll();

    @Select("select * from teacher where tno = #{tno}")
    Teacher findById(Integer tno);

    @Delete("delete from teacher where tno = #{tno}")
    int deleteById(Integer tno);

    @Update("update teacher set tname = #{tname}," +
            "phoneNumber = #{phoneNumber}, email = #{email},password = #{password}," +
            "institute = #{institute} where tno = #{tno}")
    int update(Teacher teacher);

    @Options(useGeneratedKeys = true,keyProperty = "tno")
    @Insert("insert into teacher(tname,tno,phoneNumber,email,password,institute) " +
            "values(#{tname},#{tno},#{phoneNumber},#{email},#{password},#{institute})")
    int add(Teacher teacher);
}
